from flask_restful import Api
from resources.user import UserList, UserDetail
from resources.family import FamilyList, FamilyDetail
from resources.dish import DishList, DishDetail
from resources.category import CategoryList, CategoryDetail
from resources.cart import CartList, CartDetail
from resources.note import NoteList, NoteDetail
from resources.pending_dish import PendingDishList, PendingDishDetail
from resources.bill import BillCategoryList, BillCategoryDetail, BillSubCategoryList, BillSubCategoryDetail, RecordList, RecordDetail
from resources.scheduled_task import ScheduledTaskList, ScheduledTaskDetail

def register_routes(api: Api):
    """注册API路由"""
    # 用户相关路由
    api.add_resource(UserList, '/api/users')
    api.add_resource(UserDetail, '/api/users/<int:user_id>')
    
    # 家庭相关路由
    api.add_resource(FamilyList, '/api/families')
    api.add_resource(FamilyDetail, '/api/families/<int:family_id>')
    
    # 家庭成员相关路由
    # 注意：家庭成员的增删改查在Family和User资源中处理
    
    # 菜品分类相关路由
    api.add_resource(CategoryList, '/api/categories')
    api.add_resource(CategoryDetail, '/api/categories/<int:category_id>')
    
    # 菜品相关路由
    api.add_resource(DishList, '/api/dishes')
    api.add_resource(DishDetail, '/api/dishes/<int:dish_id>')
    
    # 购物车相关路由
    api.add_resource(CartList, '/api/carts')
    api.add_resource(CartDetail, '/api/carts/<int:cart_id>')
    
    # 便签相关路由
    api.add_resource(NoteList, '/api/notes')
    api.add_resource(NoteDetail, '/api/notes/<int:note_id>')
    
    # 待做菜品相关路由
    api.add_resource(PendingDishList, '/api/pending-dishes')
    api.add_resource(PendingDishDetail, '/api/pending-dishes/<int:pending_dish_id>')
    
    # 账单分类相关路由
    api.add_resource(BillCategoryList, '/api/bill-categories')
    api.add_resource(BillCategoryDetail, '/api/bill-categories/<int:category_id>')
    
    # 账单子分类相关路由
    api.add_resource(BillSubCategoryList, '/api/bill-sub-categories')
    api.add_resource(BillSubCategoryDetail, '/api/bill-sub-categories/<int:sub_category_id>')
    
    # 账单记录相关路由
    api.add_resource(RecordList, '/api/records')
    api.add_resource(RecordDetail, '/api/records/<int:record_id>')
    
    # 定时任务相关路由
    api.add_resource(ScheduledTaskList, '/api/scheduled-tasks')
    api.add_resource(ScheduledTaskDetail, '/api/scheduled-tasks/<int:task_id>')